﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Markup;

namespace DotNetZen.Presentation.Converters
{
    [ContentProperty("Laundry")]
    public class MultiBindingFoldingConverter : IMultiValueConverter
    {
        #region IMultiValueConverter Members

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // Check to see that laundry is not null
            if (laundry == null)
                throw new ArgumentNullException("laundry");

            object value = this.laundry.Convert(values, targetType, culture);

            return value;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            // Check to see that laundry is not null
            if (laundry == null)
                throw new ArgumentNullException("laundry");

            object[] returnedValues = new object[targetTypes.Length].FillWith(Binding.DoNothing);

            this.laundry.ConvertBack(value, targetTypes, culture, returnedValues);

            return returnedValues;
        }

        #endregion

        #region Fold Laundry { get; set; } (laundry)
        private Fold laundry;

        /// <summary>
        /// Gets or sets the final fold of the laundry.
        /// </summary>
        [System.ComponentModel.Description("Indicates the final fold of the laundry.")]
        public Fold Laundry
        {
            [System.Diagnostics.DebuggerStepThrough]
            get
            {
                return this.laundry;
            }
            [System.Diagnostics.DebuggerStepThrough]
            set
            {
                if (this.laundry != value)
                {
                    this.laundry = value;
                }
            }
        }
        #endregion
    }
}
